package com.tcm.logistics.service.impl;

import com.tcm.logistics.dao.mapper.LogisticsFreightMapper;
import com.tcm.logistics.entity.LogisticsFreight;
import com.tcm.logistics.service.LogisticsFreightService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService(version = "0.0.1-alpha")
public class LogisticsFreightServiceImpl implements LogisticsFreightService {

    @Autowired
    private LogisticsFreightMapper logisticsFreightMapper;

    /**
     * 运费模板
     *
     * @param shopId
     * @return
     */
    @Override
    public List<LogisticsFreight> listFreight(Long shopId) {
        return logisticsFreightMapper.listFreight(shopId);
    }

    /**
     * 获得运费模板
     *
     * @param id
     * @return
     */
    @Override
    public LogisticsFreight findById(Long id, Long shopId) {
        return logisticsFreightMapper.findByKey(id, shopId);
    }

    /**
     * 新增运费模板
     *
     * @param logisticsFreight
     */
    @Override
    public void create(LogisticsFreight logisticsFreight) {
        logisticsFreightMapper.insert(logisticsFreight);
    }

    /**
     * 更新运费模板
     *
     * @param logisticsFreight
     */
    @Override
    public void update(LogisticsFreight logisticsFreight) {
        logisticsFreightMapper.updateByKey(logisticsFreight);
    }

    /**
     * 逻辑删除运费模板
     *
     * @param id
     * @param shopId
     * @return
     */
    @Override
    public int deleteLogicById(Long id, Long shopId) {
        return logisticsFreightMapper.deleteLogicByKey(id, shopId);
    }

    /**
     * 删除运费模板
     *
     * @param id
     * @param shopId
     * @return
     */
    @Override
    public int deleteById(Long id, Long shopId) {
        return logisticsFreightMapper.deleteByKey(id,shopId);
    }
}
